<template>
	<view class="bigbox">
		
		<view class="fuwu" >
			
			<view>教练名:</view>
		<view class="yang"><input type="text" v-model="coachname" /></view>
		</view>
		<view class="fuwu" >
			
			<view>教练课程:</view>
		<view class="yang"><input type="text" v-model="coachcourse" /></view>
		</view>
	<view class="fuwu">
	
		<view>教练服务</view>
		<view>❤❤❤❤❤</view>
	</view>
	<view class="ganshou">
		<view class="gan">训练感受</view>
		<view class="tanyou">
	
			<uni-data-checkbox mode="tag" :multiple="true" v-model="checkbox3" :localdata="hobby" @change="xunliansense"></uni-data-checkbox>
			
		</view>
		
	</view>
	<view class="kuang">
	<textarea placeholder="课程是否满足了你的期待?说说你的训练心得分享给其他想参与的朋友吧。" v-model="wenben" @click="kan"></textarea>
	</view>
	<view class="tijiao">
		<button size="mini" type="primary" @click="submit">提交评价</button>
	</view>
	</view>
</template>

<script>
	import {toRefs,reactive} from 'vue';
	import myRequest from '../../../utils/myRequest.js';
	export default {
		setup(){
			let data=reactive({
				checkbox3: [0],
				// addsense:[],
				sense:[],
				wenben:'',
				coachname:'',
				imgsrc:'["蔡徐坤.jpeg"]',
				coachcourse:'',
				hobby: [{
									text: '比较吃力',
									value: 0
								}, {
									text: '适合小白',
									value: 1
								}, {
									text: '感觉吃力',
									value: 2
								}, {
									text: '训练适中',
									value: 3
								}],
								xunliansense(e){
									let arr=[]
									// console.log(e)
									for(let i=0;i<e.detail.data.length;i++){
										arr.push(e.detail.data[i].text)
									}
											data.sense=arr
											// console.log(data.sense)
											},
											
											submit(){
												let addsense={
													src:'蔡徐坤.jpeg',
													coachcourse:data.coachcourse,
													coachtime:'19.00-20.00',
													coachname:data.coachname,
													coachsense:JSON.stringify(data.sense),
													imgsrc:data.imgsrc,
													coachcomment:data.wenben
												}
												
												// console.log(addsense)
												myRequest({
													url:'/addcoachcomment',
													method:'post',
													data:addsense
												}).then((res)=>{
													// console.log(res)
													
													uni.navigateTo({
														url: '/pages/My/comment/comment'
													});
													uni.showToast({
														title: '评论成功',
														duration: 1000
													});
												})
											}
											
			});
			return {...toRefs(data)}
		}
	}
</script>

<style lang="less" scoped>
.bigbox{
	background-color: rgb(249,249,249);
	padding:30rpx ;
}
.fuwu{
	display: flex;
	align-items: center;
	padding: 20rpx 30rpx;
	box-sizing: border-box;
	width: 690rpx;
background-color: white;
	margin-bottom: 20rpx;
	view:nth-child(1){
		font-size: 28rpx;
		color: rgb(165,153,165);
		margin-right: 30rpx;
	}
	view:nth-child(2){
		color: red;
	}
}
.ganshou{
	background-color: white;
	padding: 20rpx 30rpx;
	display: flex;
	margin-bottom: 20rpx;
	align-items: center;
	font-size: 28rpx;
	.gan{
			margin-right: 30rpx;
			color: rgb(165,153,165);
	}
}
textarea{
	background-color: white;
	padding: 20rpx 30rpx;
}
.kuang{
	width: 690rpx;
	background-color: white;
	font-size: 28rpx;
}
textarea{
	
}
.tijiao{
	text-align: center;
	margin-top: 20rpx;
}
.yang{
	color: black!important;
	font-size: 28rpx;
}
</style>